import $V from './$V';

export default function arbr(open, high, low, close, length = 26) {
    let ar = $V.init(open.length, 50);
    let br = $V.init(open.length, 50);
    for(let i = length + 1; i < open.length; i++) {
        ar[i] = $V.sum($V.sub($V.subv(high, i - length, i), $V.subv(open, i - length, i))) / $V.sum($V.sub($V.subv(open, i - length, i), $V.subv(low, i - length, i))) * 50;
        let temp1 = $V.sub($V.subv(high, i - length, i), $V.subv(close, i - length - 1, i - 1));
        let temp2 = $V.sub($V.subv(close, i - length - 1, i - 1), $V.subv(low, i - length, i));
        br[i] = $V.sum(temp1) / $V.sum(temp2) * 50;
    }
    return { ar, br };
}
